<?php
$bar_active = 'accessories';
$current_url = '/'.$_GET['alias'].'/';
if($_GET['catalias'] == '') {
   $query_cat = '';
   $curr_cat = '';
   $seo_meta = get_seo_meta(0,'categories','Phụ kiện','Hệ thống bán lẻ phụ kiện điện thoại, phụ kiện máy tính bảng số 1 Việt Nam. Chuyên bán lẻ phụ kiện điện thoại, phụ kiện máy tính bảng, Nokia, Samsung, iPhone, LG, HTC, BlackBerry,... mới chính hãng, giá tốt');
}else {
   $query_cat = ' AND cat_alias = "'.$_GET['catalias'].'"';
   $curr_cat = db_first('SELECT * FROM categories WHERE cat_alias = "'.$_GET['catalias'].'"');
   if(!$curr_cat) not_found();
   $seo_meta = get_seo_meta($curr_cat['cat_id'],'categories',$curr_cat['cat_name'],'Hệ thống bán lẻ phụ kiện điện thoại, phụ kiện máy tính bảng số 1 Việt Nam. Chuyên bán lẻ phụ kiện điện thoại, phụ kiện máy tính bảng, Nokia, Samsung, iPhone, LG, HTC, BlackBerry,... mới chính hãng, giá tốt');
}
//sap xep gia
$filter_price = getValue('gia','str','GET','');
$filter_view = getValue('sx','str','GET','');
$tt_view = '&';
switch($filter_price) {
   case 'duoi-1-trieu':
      $query_price = ' AND acc_price <= 1000000';
      $current_filter_price = 'gia=duoi-1-trieu';
      break;
   case 'duoi-2-trieu':
      $query_price = ' AND acc_price <= 2000000';
      $current_filter_price = 'gia=duoi-2-trieu';
      break;
   case 'duoi-3-trieu':
      $query_price = ' AND acc_price <= 3000000';
      $current_filter_price = 'gia=duoi-3-trieu';
      break;
   case 'duoi-5-trieu':
      $query_price = ' AND acc_price <= 5000000';
      $current_filter_price = 'gia=duoi-5-trieu';
      break;
   case 'duoi-8-trieu':
      $query_price = ' AND acc_price <= 8000000';
      $current_filter_price = 'gia=duoi-8-trieu';
      break;
   case 'duoi-10-trieu':
      $query_price = ' AND acc_price <= 10000000';
      $current_filter_price = 'gia=duoi-10-trieu';
      break;
   case 'tren-10-trieu':
      $query_price = ' AND acc_price >= 10000000';
      $current_filter_price = 'gia=tren-10-trieu';
      break;
   default:
      $query_price = '';
      $current_filter_price = '';
      break;
}
switch($filter_view) {
   case 'xem-nhieu-nhat':
      $query_view = 'ORDER BY acc_view DESC';
      $current_filter_view = 'sx=xem-nhieu-nhat';
      break;
   case 'gia-cao-den-thap':
      $query_view = 'ORDER BY acc_price DESC';
      $current_filter_view = 'sx=gia-cao-den-thap';
      break;
   case 'gia-thap-den-cao':
      $query_view = 'ORDER BY acc_price ASC';
      $current_filter_view = 'sx=gia-thap-den-cao';
      break;
   default:
      $query_view = 'ORDER BY acc_id DESC';
      $current_filter_view = '';
      break;
}

$list_products = db_array('SELECT *
                           FROM accessories
                           LEFT JOIN categories ON acc_cat_id = cat_id
                           WHERE acc_active = 1'.$query_cat.$query_price.' 
                           '.$query_view.'
                           LIMIT 20');
$total_products = count($list_products);

?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="vi-VN" lang="vi-VN" xmlns:og="http://ogp.me/ns#" xmlns:fb="http://www.facebook.com/2008/fbml">
<head>
   <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
   <link href="<?=DOMAIN?>/favicon.ico" type="image/x-icon" rel="shortcut icon"/>
   <meta name="viewport" content="width=device-width, initial-scale=1.0"/>
   <?php echo $seo_meta;?>
   <!-- css -->
   <link rel="stylesheet" type="text/css" href="/themes/css/base.css"/>
   <link rel="stylesheet" type="text/css" href="/themes/css/product.css"/>
   <link rel="stylesheet" type="text/css" href="/themes/css/mobile.css"/>

   <script type="text/javascript" src="/themes/js/jquery-1.9.0.min.js"></script>
   <script type="text/javascript" src="/themes/js/common.js"></script>
   <script type="text/javascript" src="/themes/js/site.js"></script>
   <?=$facebook_script?>
</head>
<body>
   <?php include 'view/view_header.php'?>
   <?php include 'view/view_accessories.php'?>
   <?php include 'view/view_support.php'?>
   <?php include 'view/view_footer.php'?>
</body>
</html>